Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more btests to replace "unit" tests #417

Merged
merged 9 commits into from
Jul 14, 2024

Conversation

Neverlord
Copy link
Member

Since we have access to btest in Broker for a while now, it's about time we replace some of our "unit" tests with btest-based tests instead. Historically, we have used a special fixture setup in Broker for tests that need multiple Broker endpoints to get around having to orchestrate multiple processes. This is really just working around the limitations we had at the time, i.e., only having access to a unit test framework but really needed to have system tests in place.

This isn't just about swapping tools, because the setup for these "unit" tests:

  • uses some rather low-level CAF APIs
  • requires in-depth knowledge about implementation details of the unit test framework
  • forces us to ship code in Broker that only exists to make the unit tests work (will be removed as a followup)
  • bypasses user-facing APIs such as peer and listen, which means we test against internal implementations details of Broker and some user-facing APIs remain untested

The new btest connects to Broker endpoints and then publishes data on
one endpoint while receiving on the other.
The `base_fixture` is quite heavyweight and some tests, like the
`multipath` test suite, uses the fixture only for `id_by_value`. Pushing
this functionality to a new fixture reduces unnecessary dependencies on
the base fixture, allowing us to make more aggressive changes to it in
the future (or to remove it entirely).
With the new btest, we cover all the APIs tested in the `publisher`,
`subscriber` and `status_subscriber` "unit" tests. Since the old tests
are actually system tests that no longer add any value over the new
btest suites, we can now get rid of them.
The legacy `master.test.cc` file really only tests `put_unique`. Since
we already have a btest for that, this no longer adds any value.
Furthermore, the test really is a system test that relies on a complex
fixture setup that we want to get rid of.
The legacy `integration` test suite covers forwarding and unpeering. We
have new btest-based system tests for both now and thus no longer need
the legacy test.
The `channel` test suite relies on the low-level `base_fixture` setup
but really doesn't need actors. This new implementation simply
dispatches to producers and consumers directly from the list of outgoing
messages that we keep anyways to simulate loss rates, without needing to
go through the extra abstraction of actors.
The core actor unit test suite really only tests forwarding between
peers. However, we already have added a btest covering that, so this
test no longer serves a purpose.
@Neverlord Neverlord marked this pull request as ready for review July 7, 2024 15:05
Copy link
Member

@timwoj timwoj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this. It adds a bunch of good, clear examples of using the broker API for messaging without any additional steps.

@Neverlord Neverlord merged commit 2777023 into master Jul 14, 2024
20 checks passed
@Neverlord Neverlord deleted the topic/neverlord/system-tests branch July 14, 2024 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants